import request from '@/utils/request'

export default {
  // 1.获取权限列表
  getRightsList (type) {
    return request({
      url: `rights/${type}`,
      method: 'get'
    })
  },

  // 2.获取角色列表
  getRolesList () {
    return request({
      url: 'roles',
      method: 'get'
    })
  },

  // 3.删除角色指定的权限
  delRoleRights (roleId, rightId) {
    return request({
      url: `roles/${roleId}/rights/${rightId}`,
      method: 'delete'
    })
  },

  // 4.分配角色权限
  allocRoleRights (roleId, idStr) {
    return request({
      url: `roles/${roleId}/rights`,
      method: 'post',
      data: {
        rids: idStr
      }
    })
  },

  // 5.分配用户角色
  setUserRole (id, rid) {
    return request({
      url: `users/${id}/role`,
      method: 'put',
      data: {
        rid: rid
      }
    })
  }
}
